package com.uuah.server.api.component.service;

import java.beans.ExceptionListener;
import java.io.Serializable;

import com.uuah.api.INamedObject;
import com.uuah.api.lifecycle.ILifecycle;
import com.uuah.server.api.IUuahContext;
import com.uuah.server.api.IUuahEvent;
import com.uuah.server.api.IUuahMessage;
import com.uuah.server.api.channel.IChannel;
import com.uuah.server.api.component.IComponent;
import com.uuah.server.api.component.model.IModel;
import com.uuah.server.api.context.IUuahContextAware;
import com.uuah.server.exception.AbstractUuahServerException;

/**
 * * <code>Service</code> is the internal representation of a Uuaah AppServer Managed
 * service. It is responsible for managing the interaction of events to and from
 * the service as well as managing pooled resources.
 *
 * @author <a href="jonny_quan@hotmail.com">jonny</a>
 * @date 2008 2008-10-10 03:52:00
 * @version 1.0.0<br>
 *
 *
 */
public interface IService extends Serializable, ILifecycle, IUuahContextAware,
		INamedObject {

	/**
	 *
	 *
	 * @param event
	 * @throws AbstractUuahServerException
	 */
	void dispatchEvent(IUuahEvent event) throws AbstractUuahServerException;

	/**
	 *
	 *
	 * @param event
	 * @return
	 * @throws AbstractUuahServerException
	 */
	IUuahMessage sendEvent(IUuahEvent event) throws AbstractUuahServerException;

	/**
	 *
	 *
	 * @return
	 */
	boolean isStarted();

	/**
	 *
	 * @throws AbstractUuahServerException
	 */
	void pause() throws AbstractUuahServerException;

	/**
	 *
	 *
	 * @throws AbstractUuahServerException
	 */
	void resume() throws AbstractUuahServerException;

	/**
	 *
	 *
	 * @return
	 */
	boolean isPaused();

	/**
	 *
	 *
	 * @return
	 */
	ExceptionListener getExceptionListener();

	/**
	 *
	 * @return
	 */
	IChannel getRequestChannel();

	/**
	 * *
	 *
	 * @return
	 */
	String getInitialState();

	/**
	 *
	 * @return
	 */
	IModel getModel();

	/**
	 *
	 * @param listener
	 */
	void setExceptionListener(ExceptionListener listener);

	/**
	 *
	 * @param channel
	 */
	void setRequestChannel(IChannel channel);

	/**
	 *
	 * @param state
	 */
	void setInitialState(String state);

	/**
	 *
	 * @param model
	 */
	void setModel(IModel model);

	/**
	 *
	 * @return
	 */
	IComponent getComponent();

	/**
	 *
	 * @param component
	 */
	void setComponent(IComponent component);

	/**
	 *
	 * @return
	 */
	IUuahContext getUuahContext();
}
